package com.epoint.mobileoa.ui.notice;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.dom4j.Element;

import android.os.Message;

import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.Task;
import com.epoint.mobileoa.datanalysis.XMLHelp;
import com.epoint.mobileoa.http.HttpHelp;
import com.epoint.mobileoa.model.FeedBackModel;

/**
 * @author liyc
 * @time 2012-7-9 下午7:32:59
 * @annotation 
 */
public class GetFeedBackInfoTask extends Task {

	/**
	 * @param con
	 * @param param
	 */
	public GetFeedBackInfoTask(SuperView con, HashMap<String, Object> param) {
		super(con, param);
	}

	@Override
	public void exectue(Message mess) throws Exception {
		String infoguid = getParam().get("infoguid").toString();
		String url = generateURL("GetFeedBackInfo",infoguid);
		String bs = HttpHelp.getHttpBack(url);
		setMessageToRefreshUI(mess, getCon(), bs);
	}
	
	public static List<FeedBackModel> XmlAnalysis(String xml){
		List focs = XMLHelp.getRoot(xml).elements();
		List<FeedBackModel> plist = new ArrayList<FeedBackModel>();
		for (int i = 0; i < focs.size(); i++) {
			FeedBackModel mt = new FeedBackModel();
			Element foc = (Element) focs.get(i);
			if (foc.element("content") != null)
				mt.content = foc.elementText("content");
			if (foc.element("postdisplayname") != null)
				mt.postdisplayname = foc.elementText("postdisplayname");
			if (foc.element("postdate") != null)
				mt.postdate = foc.elementText("postdate");
			plist.add(mt);
		}
		return plist;
	}

}
